package com.infosystem.demo.entities;

import com.infosystem.demo.models.EmployeeDTOI;
import jakarta.persistence.*;

import java.sql.Date;
import java.util.List;
import java.util.UUID;

@Entity
public class Employee {
    @Id
    private String id;
    private String name;
    private String govId;
    private String department;
    private Date enrollDate;

    @OneToMany(mappedBy = "employee", cascade = CascadeType.ALL, orphanRemoval = true)
    private List<Relative> relatives;
    @OneToOne(mappedBy = "employee", cascade = CascadeType.ALL, orphanRemoval = true)
    private Resume resume;

    public Employee() {
    }

    public Employee(String name, String govId, String department, Date enrollDate) {
        this.id = UUID.randomUUID().toString();
        this.name = name;
        this.govId = govId;
        this.department = department;
        this.enrollDate = enrollDate;
    }

    public Employee(EmployeeDTOI employeeDTOI){
        this.id = UUID.randomUUID().toString();
        this.name = employeeDTOI.getName();
        this.govId = employeeDTOI.getGovId();
        this.department = employeeDTOI.getDepartment();
        this.enrollDate = employeeDTOI.getEnrollDate();

    }

    public String getId() {return id;}

    public String getName() {return name;}
    public void setName(String name) {this.name = name;}

    public String getGovId() {return govId;}
    public void setGovId(String govId) {this.govId = govId;}

    public String getDepartment() {return department;}
    public void setDepartment(String department) {this.department = department;}

    public Date getEnrollDate() {return enrollDate;}
    public void setEnrollDate(Date enrollDate) {this.enrollDate = enrollDate;}

    public List<Relative> getRelatives() {return relatives;}
    public void setRelatives(List<Relative> relatives) {this.relatives = relatives;}

    public Resume getResume() {return resume;}
    public void setResume(Resume resume) {this.resume = resume;}
}
